healthiar R package workshop 1 for WP5
2025-03-24
Let’s start by checking out the BEST-COST GitHub repo and the README file
healthiar in RStudio 1/2Post installation, you can access the healthiar package landing page in RStudio by going to the Packages tab and then clicking on the healthiar package.
healthiar in RStudio 2/2Landing page of the healthiar package in RStudio, where you find the package vignettes and function documentation.
attribute call without input uncertaintiesAttribute COPD cases to air pollution
results_pm_copd <-
healthiar::attribute_health(
erf_shape = "log_linear",
rr_central = exdat_pm_copd$relative_risk,
rr_lower = exdat_pm_copd$relative_risk_lower,
rr_upper = exdat_pm_copd$relative_risk_upper,
rr_increment = 10,
exp_central = exdat_pm_copd$mean_concentration,
cutoff_central = exdat_pm_copd$cut_off_value,
bhd_central = exdat_pm_copd$incidents_per_100_000_per_year/1E5*exdat_pm_copd$population_at_risk,
# bhd_central = exdat_pm_copd$incidence # Uncomment once change committed to main
) Every attribute output consists of two lists (“folders”)
health_main contains the main results
health_detailed detailed results (and in some cases even more information about the assessment/calculation)
Tip
This is really about personal preference! However, you might encounter them all.
results_pm_copd[["health_main"]]
Note: if the cursor is located within the square braces you can see all available options by pressing the tab key
results_pm_copd$health_main$impact_rounded
Note: after typing the $ sign you can see all available options by pressing the tab key and use the arrows & tab keys to select an option (or alternatively use the mouse)
Using the purrr::pluck function to select a list and then the dplyr::pull function extract values from a specified column
results_pm_copd |> purrr::pluck("health_main") |> dplyr::pull("impact_rounded")
Note: available options can’t be displayed automatically using these functions -> better suited for a more permanent analysis script
View(results_pm_copd) will “open” the variable in a new window within RStudio. Alternatively, you can go to the Environment tab and click on the variable to open the same view mode.
attribute call with input uncertaintiesTip
See the intro vignette for a detailed description of output columns (coming soon)
This is what the health_detailed output table looks like
| geo_id_disaggregated | erf_ci | exp_ci | bhd_ci | cutoff_ci | pop_fraction | impact | prop_pop_exp | rr_increment | erf_shape | exposure_name | approach_risk | health_outcome | exposure_dimension | exposure_type | exp | rr | bhd | cutoff | pop_fraction_type | rr_conc | impact_rounded |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | central | central | central | central | 0.1138961 | 3501.9619 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.85 | 1.369 | 30747 | 5 | paf | 1.128536 | 3502 |
| 1 | central | central | lower | central | 0.1138961 | 3189.0894 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.85 | 1.369 | 28000 | 5 | paf | 1.128536 | 3189 |
| 1 | central | central | upper | central | 0.1138961 | 3644.6736 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.85 | 1.369 | 32000 | 5 | paf | 1.128536 | 3645 |
| 1 | lower | central | central | central | 0.0440064 | 1353.0658 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.85 | 1.124 | 30747 | 5 | paf | 1.046032 | 1353 |
| 1 | lower | central | lower | central | 0.0440064 | 1232.1801 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.85 | 1.124 | 28000 | 5 | paf | 1.046032 | 1232 |
| 1 | lower | central | upper | central | 0.0440064 | 1408.2058 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.85 | 1.124 | 32000 | 5 | paf | 1.046032 | 1408 |
| 1 | upper | central | central | central | 0.1780300 | 5473.8882 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.85 | 1.664 | 30747 | 5 | paf | 1.216589 | 5474 |
| 1 | upper | central | lower | central | 0.1780300 | 4984.8398 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.85 | 1.664 | 28000 | 5 | paf | 1.216589 | 4985 |
| 1 | upper | central | upper | central | 0.1780300 | 5696.9598 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.85 | 1.664 | 32000 | 5 | paf | 1.216589 | 5697 |
| 1 | central | lower | central | central | 0.0899213 | 2764.8092 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.00 | 1.369 | 30747 | 5 | paf | 1.098806 | 2765 |
| 1 | central | lower | lower | central | 0.0899213 | 2517.7955 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.00 | 1.369 | 28000 | 5 | paf | 1.098806 | 2518 |
| 1 | central | lower | upper | central | 0.0899213 | 2877.4806 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.00 | 1.369 | 32000 | 5 | paf | 1.098806 | 2877 |
| 1 | lower | lower | central | central | 0.0344604 | 1059.5528 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.00 | 1.124 | 30747 | 5 | paf | 1.035690 | 1060 |
| 1 | lower | lower | lower | central | 0.0344604 | 964.8902 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.00 | 1.124 | 28000 | 5 | paf | 1.035690 | 965 |
| 1 | lower | lower | upper | central | 0.0344604 | 1102.7316 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.00 | 1.124 | 32000 | 5 | paf | 1.035690 | 1103 |
| 1 | upper | lower | central | central | 0.1416706 | 4355.9450 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.00 | 1.664 | 30747 | 5 | paf | 1.165054 | 4356 |
| 1 | upper | lower | lower | central | 0.1416706 | 3966.7760 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.00 | 1.664 | 28000 | 5 | paf | 1.165054 | 3967 |
| 1 | upper | lower | upper | central | 0.1416706 | 4533.4583 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 8.00 | 1.664 | 32000 | 5 | paf | 1.165054 | 4533 |
| 1 | central | upper | central | central | 0.1453304 | 4468.4726 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 10.00 | 1.369 | 30747 | 5 | paf | 1.170043 | 4468 |
| 1 | central | upper | lower | central | 0.1453304 | 4069.2501 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 10.00 | 1.369 | 28000 | 5 | paf | 1.170043 | 4069 |
| 1 | central | upper | upper | central | 0.1453304 | 4650.5716 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 10.00 | 1.369 | 32000 | 5 | paf | 1.170043 | 4651 |
| 1 | lower | upper | central | central | 0.0567717 | 1745.5580 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 10.00 | 1.124 | 30747 | 5 | paf | 1.060189 | 1746 |
| 1 | lower | upper | lower | central | 0.0567717 | 1589.6063 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 10.00 | 1.124 | 28000 | 5 | paf | 1.060189 | 1590 |
| 1 | lower | upper | upper | central | 0.0567717 | 1816.6929 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 10.00 | 1.124 | 32000 | 5 | paf | 1.060189 | 1817 |
| 1 | upper | upper | central | central | 0.2247829 | 6911.4001 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 10.00 | 1.664 | 30747 | 5 | paf | 1.289961 | 6911 |
| 1 | upper | upper | lower | central | 0.2247829 | 6293.9214 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 10.00 | 1.664 | 28000 | 5 | paf | 1.289961 | 6294 |
| 1 | upper | upper | upper | central | 0.2247829 | 7193.0531 | 1 | 10 | log_linear | NA | relative_risk | same_input_output | 1 | population_weighted_mean | 10.00 | 1.664 | 32000 | 5 | paf | 1.289961 | 7193 |